package com.dimension.common.web;

import java.io.Serializable;

/**
 * 返回值接口规范
 * @author tuliang
 * @version $Id: WebResult.java 2018年11月1日 下午5:35:18 $
 *
 */
public class WebResult implements Serializable {

	private static final long serialVersionUID = 7356272938891591831L;
	
	private static final String STATUS_SUCCESS = "200";
	
	private static final String STATUS_FAILED = "12000";
	
	/**
	 * 返回状态 200：成功
	 */
	private String status ;
	
	/**
	 * 返回值
	 */
	private Object result;
	
	/**
	 * 错误信息
	 */
	private String msg;
	
	/**
	 * 成功
	 * @param result
	 * @return
	 */
	public static WebResult success(Object result) {
        WebResult r = new WebResult();
        r.setStatus(STATUS_SUCCESS);
        if (result != null) {
            r.setResult(result);
        }
        return r;
    }
	
	/**
	 * 失败
	 * @return
	 */
	public static WebResult failed(){
	    WebResult r = new WebResult();
	    r.setStatus(STATUS_FAILED);
	    return r;
	}
	
	/**
	 * 返回成功
	 * @param status 状态
	 * @param msg 失败内容
	 * @return
	 */
	public static WebResult failed(String status, String msg){
        WebResult r = new WebResult();
        r.setStatus(status);
        r.setMsg(msg);
        return r;
    }
	
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public Object getResult() {
		return result;
	}

	public void setResult(Object result) {
		this.result = result;
	}

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    };
	
	
	
}
